<template>
    <el-dialog v-model="open" title="结算订单" width="510px">
        <el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
            <el-form-item label="显示数里" prop="realRate1">
                <el-input v-model="formData.realRate1" placeholder="请输入实际收益率1" />
            </el-form-item>
            <el-form-item label="收益率1" prop="realRate2">
                <el-input v-model="formData.realRate2" placeholder="请输入实际收益率2" />
            </el-form-item>
            <el-form-item label="收益率2" prop="realRate3">
                <el-input v-model="formData.realRate3" placeholder="请输入实际收益率3" />
            </el-form-item>
            <el-form-item label="1结果" prop="win1">
                <el-input v-model="formData.win1" placeholder="请输入1结果" />
            </el-form-item>
            <el-form-item label="1结果" prop="win2">
                <el-input v-model="formData.win2" placeholder="请输入2结果" />
            </el-form-item>
            <el-form-item label="1结果" prop="win3">
                <el-input v-model="formData.win3" placeholder="请输入3结果" />
            </el-form-item>

        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button type="primary" :loading="loading" @click="onSubmit('formData')">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script setup>
import { reactive, ref, defineExpose, defineEmits } from 'vue'
import { settleOrder } from "@/api";
import { ElMessageBox, ElMessage } from "element-plus";
const emit = defineEmits(['loadData'])
const formRef = ref()
const open = ref(false)
const formData = reactive({
    id: "",
    realRate1: "",
    realRate2: "",
    realRate3: "",
    win1: "",
    win2: "",
    win3: "",
})
const formRules = {
    realRate1: [
        { required: true, message: '请输入实际收益率1', trigger: 'change' },
    ], realRate2: [
        { required: true, message: '请输入实际收益率2', trigger: 'change' },
    ], realRate3: [
        { required: true, message: '请输入实际收益率3', trigger: 'change' },
    ], win1: [
        { required: true, message: '请输入1结果', trigger: 'change' },
    ], win2: [
        { required: true, message: '请输入2结果', trigger: 'change' },
    ], win3: [
        { required: true, message: '请输入3结果', trigger: 'change' },
    ],
}
const loading = ref(false)
const onSubmit = async () => {
    try {
        const a = await formRef.value.validate().catch(() => null)
        if (!a) return
        open.value = false;
        const res = await settleOrder(formData);
        if (res.data.code == 20) {
            ElMessage({
                message: "成功",
                type: "success",
            });
        }
        emit("loadData")
    } catch (error) {

    }
}
const show = (row) => {
    open.value = true;
    formData.id = row.Id
    formData.realRate1 = ""
    formData.realRate2 = ""
    formData.realRate3 = ""
    formData.win1 = ""
    formData.win2 = ""
    formData.win3 = ""


}
defineExpose({
    show,
})
</script>
<style lang="scss" scoped>
.right {
    overflow: auto;
}

.el-pagination {
    padding: 15px;
    float: right;
}
</style>